package com.ajview.core.config.model;

import com.ajview.common.core.factory.YamlPropertySourceFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;


/**
 * @author ZhangJunJie
 * @Date 2022-04-29
 * <p>
 * 概要：映射核心配置文件的Security模型
 */
@PropertySource(value = "classpath:config/ajview-core-config.yml", factory = YamlPropertySourceFactory.class,
        encoding = "UTF-8")
@ConfigurationProperties(prefix = "security.config")
@Component
public class SecurityModel {
    /**
     * 超级管理员id
     */
    private Long systemUserId = 1L;

    public Long getSystemUserId() {
        return systemUserId;
    }

    public void setSystemUserId(Long systemUserId) {
        this.systemUserId = systemUserId;
    }


    /**
     * 判断是否是超级管理员
     *
     * @param userid
     * @return
     */
    public boolean isSystemUser(Long userid) {
        return getSystemUserId().equals(userid);
    }
}
